package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * Created by WF on 2020/7/29 15:42
 */
public interface FriendDao extends JpaRepository<Friend,String> {
    //1.查询好友的条数
    @Query(nativeQuery=true,value="select count(*) from tb_friend where userid=?1 and friendid=?2")
    int selectCount(String userId, String friendid);
    //2.修改islike的值
    @Query(nativeQuery=true,value="update tb_friend set islike=?1 where userid=?1 and friendid=?2")
    @Modifying
    void updateLike(String s, String userId, String friendid);
    @Modifying
    @Query(nativeQuery=true,value="delete from tb_friend where userid=?1 and friendid=?2")
    void deleteByUserId(String userid,String friendid);
}
